package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.CPReportService;
import com.yixun.qfbao.apidto.BatchReportReqDto;
import com.yixun.qfbao.apidto.BatchReportResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.BatchReportReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @classname: CheckReportListHander.java
 * @author: Beau
 * @create: 2020/02/10 23:23
 * @version: 1.0.0
 **/
@Service("checkReportListHander")
public class CheckReportListHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(CheckReportListHander.class);

    @Autowired
    private CPReportService cpReportService;
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        BatchReportReqVo reqDto1 = (BatchReportReqVo) reqDto;
        BatchReportReqDto params = reqDto1.getParams();
        BaseResponseDTO<BatchReportResDto> res = new BaseResponseDTO<BatchReportResDto>();
        BatchReportResDto resDto = new BatchReportResDto();
        try {
            resDto = cpReportService.checkBatchReport(params);
        } catch (Exception e) {
            logger.error("CheckReportListHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("校验异常");
        }
        res.setResult(resDto.getResult());
        res.setResData(resDto);
        return res;
    }
}
